package com.sn.seabattle;

import java.io.IOException;
import java.util.UUID;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;

public class Server extends Thread {
    private BluetoothServerSocket s;
    private MainSB home;

    public Server(BluetoothAdapter BTA, MainSB h) {
        this.home = h;
        BluetoothServerSocket tmp = null;
        try {
            tmp = BTA.listenUsingRfcommWithServiceRecord("SeaBattle",
                    UUID.fromString("10011001-1011-1101-8000-00805F9B34FB"));
        } catch (IOException e) {
        }
        s = tmp;
        start();
    }

    public void run() {
        BluetoothSocket socket = null;
        report("server");
        try {
            socket = s.accept();
           // home.report("server used");
        } catch (IOException e) {
        }

    }

    private void report(String s){
        home.report(s);
    }
}
